#!/usr/bin/python
# -*- coding: utf-8 -*-
# @name             : 数据生成器
# @author           : OneYoung
# @create           : 2024/02/04
# @version          : v1.0
# @desc             : 随机生成相关数据

from faker import Faker

"""
使用faker类生成随机信息,其他随机信息可以通过RandomInfo.faker.func_name()实现
示例：faker.date()
配置参考 https://faker.readthedocs.io/en/master/
"""

faker = Faker(locale='zh_CN')


def random_number(length: int):
    """
    生成特定长度的随机数字串
    :param length: 长度
    """
    return faker.random_number(length)


def random_letter(length: int):
    """
    生成特定长度的随机小写字母串
    :param length: 长度
    """
    letter = ""
    for _ in range(0, length):
        letter += faker.random_lowercase_letter()
    return letter


def random_capital_letter(length: int):
    """
    生成特定长度的随机大写字母串
    :param length: 长度
    """
    capital_letter = random_letter(length)
    return capital_letter.upper()


def random_number_capital(length: int):
    """
    生成特定长度的数字和大写字母混合串
    :param length: 长度
    """
    mixture_arr = str(random_number(length)) + random_capital_letter(length)
    mixture = faker.random_sample(mixture_arr, length)
    r_mixture = "".join(mixture)
    return r_mixture


def random_mixture(length: int):
    """
    生成特定长度的大小写字母及数字随机混合串
    :param length: 长度
    """
    mixture_arr = f'{random_number(length)}{random_letter(length)}'
    mixture = faker.random_sample(mixture_arr, length)
    r_mixture = "".join(mixture)
    return r_mixture


def random_mixture_letter(length: int):
    """
    生成特定长度的大小写字母随机混合串
    :param length: 长度
    """
    mixture = faker.random_letters(length=length)
    r_mixture_letter = "".join(mixture)
    return r_mixture_letter


def random_name():
    """生成随机的汉字姓名"""
    return faker.name()


def random_phone():
    """生成随机手机号码"""
    return faker.phone_number()


def random_email():
    """生成随机邮箱地址"""
    return faker.email()


def random_id_card_no():
    """生成随机身份证号码"""
    return faker.ssn()


def random_company():
    """生成随机公司名称"""
    return faker.company()


def random_card_number():
    """生成随机信用卡号"""
    return faker.credit_card_number()


def random_image_url():
    """生成随机图片地址"""
    return faker.image_url()


def random_address():
    """生成随机详细地址"""
    return faker.address()


def random_text(length: int):
    """
    生成特定长度文本
    :param length: 长度,需大于4
    """
    return faker.text(max_nb_chars=length)


def random_uuid():
    """生成随机UUID"""
    return faker.uuid4()


def random_md5():
    """随机生成MD5"""
    return faker.md5()


def random_sha1():
    """随机生成sha1"""
    return faker.sha1()
